package com.tsinghua.server.base.controller;


import com.tsinghua.server.common.Result;
import com.tsinghua.server.base.service.CaptchaService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 验证码接口
 */
@RestController
@RequestMapping(value = "/open/captcha/")
@RequiredArgsConstructor
public class CaptchaController {

    private final CaptchaService captchaService;


    /**
     * 获取验证码
     * @param code  前端生成
     * @return
     */
    @GetMapping(value = "images/{code}")
    public Result create(@PathVariable String code) {
        return Result.succ(captchaService.create(code));
    }

    @GetMapping(value = "imagess")
    public String create() {
        return "SSSS";
    }
}
